﻿using System;
using Hallenberg.Core;

namespace Hallenberg.SmartClient.Events
{
    public class HandlesEventInline<T> : HandlesEvent<T>
    {
        private bool m_Async;
        private EventHandler<EventArgs<T>> m_OverrideEventHandler;

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
        public HandlesEventInline(bool async, EventHandler<EventArgs<T>> overrideEventHandler)
        {
            m_Async = async;
            m_OverrideEventHandler = overrideEventHandler;
        }

        internal override void OnEvent(object sender, EventArgs<T> args)
        {
            m_OverrideEventHandler(sender, args);
        }

        protected override bool IsAsync()
        {
            return m_Async;
        }
    }
}
